package com.example.demo.common

import com.example.demo.exception.ErrorCode

class ResultUtils {


    companion object {
        /**
         * 成功
         */
        fun success(data: Any): BaseResponse<Any> {
            return BaseResponse(0,"ok",data)
        }

        /**
         * 失败
         */
        fun error(code : Int, msg: String): BaseResponse<Any> {
            return BaseResponse(code,msg,null)
        }

        /**
         * 失败
         */

        fun error(errorCode: ErrorCode, msg: String): BaseResponse<Any> {
            return BaseResponse(errorCode.code, msg, null)
        }

        /**
         * 失败
         */
        fun error(errorCode: ErrorCode, data: Any, msg: String): BaseResponse<Any> {
            return BaseResponse(errorCode.code, msg, data)
        }
    }


}